Improve Error Handling with Serialized File Detection#58
Open
SkowronskiAndrew wants to merge 2 commits intoimprove-error-handlingfrom
Open
Improve Error Handling with Serialized File Detection#58SkowronskiAndrew wants to merge 2 commits intoimprove-error-handlingfrom
SkowronskiAndrew wants to merge 2 commits intoimprove-error-handlingfrom
Conversation
Improve error reporting from serialized-file command Use detection helpers to print more informative messages when command is run against the wrong file type. Adding "header" subcommand for serialized file to print info from the serialized file header. Detect and specific warning for YAML (text) format SerializedFiles Example: $ UnityDataTool.exe sf header .\AssetBundle.buildreport Version 22 Format Modern (64-bit) File Size 12,280 bytes Metadata Size 6,085 bytes Data Offset 6,144 Endianness Little Endian Example: $ UnityDataTool.exe sf objectlist .\Scene1.unity Error: The file is a YAML-format SerializedFile, which is not supported. File: C:\UnitySrc\unity\Modules\ContentBuild\Tests\ContentBuildTests\Assets\Scenes\Scene1.unity UnityDataTool only supports binary-format SerializedFiles.
770b0b2 to
ce802a6
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request enhances the SerializedFile command with robust file type detection and improved error handling. It introduces three new detector utilities to differentiate between Unity Archives, YAML-format SerializedFiles, and binary SerializedFiles, replacing the previous archive detection code with a more maintainable, reusable implementation. The PR adds a new header subcommand that displays SerializedFile header information without requiring full file parsing.
Changes:
- Added three new file format detector utilities (ArchiveDetector, YamlSerializedFileDetector, SerializedFileDetector) with comprehensive header parsing
- Introduced a new
headersubcommand for quick SerializedFile inspection - Enhanced error messages to guide users when they attempt to analyze unsupported file formats (archives, YAML files)
- Added comprehensive test coverage with 13 new unit tests and 7 integration tests
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Analyzer/Util/ArchiveDetector.cs | New utility to detect Unity Archive files by signature (replaces inline code in SerializedFileParser) |
| Analyzer/Util/YamlSerializedFileDetector.cs | New utility to detect YAML-format SerializedFiles with BOM handling |
| Analyzer/Util/SerializedFileDetector.cs | New utility to detect and parse binary SerializedFile headers, supporting legacy and modern formats |
| UnityDataTool/SerializedFileCommands.cs | Added ValidateSerializedFile method with improved error messages, new HandleHeader command, updated error handling in existing commands |
| UnityDataTool/Program.cs | Registered new header subcommand with command-line parser |
| Analyzer/SQLite/Parsers/SerializedFileParser.cs | Refactored to use new detector utilities instead of inline archive detection |
| Analyzer.Tests/FileDetectionTests.cs | Added 13 comprehensive unit tests for all three detector utilities |
| UnityDataTool.Tests/SerializedFileCommandTests.cs | Added 7 integration tests for header command and improved error handling validation |
| TestCommon/Data/YamlFormat.asset | Test data file for YAML SerializedFile detection |
| Documentation/command-serialized-file.md | Added documentation for header subcommand with examples and field descriptions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enhances SerializedFile command with improved file type detection and better error reporting for analyze operations.
Key Changes
SerializedFileDetector,ArchiveDetectorandYamlSerializedFileDetector.cs utilitiesTesting
FileDetectionTestsandSerializedFileCommandTestswith legacy and YAML format test dataDocumentation
New "header" subcommand is documented, along with some high level explanation of the serialized file format.
Example:
$ UnityDataTool.exe sf header .\AssetBundle.buildreport
Version 22
Format Modern (64-bit)
File Size 12,280 bytes
Metadata Size 6,085 bytes
Data Offset 6,144
Endianness Little Endian
Example:
$ UnityDataTool.exe sf objectlist .\Scene1.unity
Error: The file is a YAML-format SerializedFile, which is not supported.
File: C:<fullpath>\Assets\Scenes\Scene1.unity
UnityDataTool only supports binary-format SerializedFiles.